package tests;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

import lib.Utility;

/**
 * Helper methods for unit tests
 * 
 * @author abhip
 * 
 */
public class TestHelpers {
    private static String TempDirPrefix = "TestHelpersTempDirs";

    public static File GetTempDirectory() throws IOException {
        return GetTempDirectory(true);
    }

    public static File GetTempDirectory(boolean ensureExists)
            throws IOException {
        File curDir = Utility.GetCurrentWorkingDirectory();
        UUID randomUUID = UUID.randomUUID();
        File tempDir = new File(new File(curDir, TempDirPrefix),
                randomUUID.toString());

        if (ensureExists) {
            tempDir.mkdirs();
        }

        return tempDir;
    }
}
